package com.dkd.web.controller.student;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dkd.student.domain.StuScores;
import com.dkd.student.service.IStuScoresService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;

/**
 * 成绩信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-20
 */
@RestController
@RequestMapping("/student/scores")
public class StuScoresController extends BaseController
{
    @Autowired
    private IStuScoresService stuScoresService;

    /**
     * 查询成绩信息列表
     */
    @PreAuthorize("@ss.hasPermi('student:scores:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuScores stuScores)
    {
        startPage();
        List<StuScores> list = stuScoresService.selectStuScoresList(stuScores);
        return getDataTable(list);
    }

    /**
     * 导出成绩信息列表
     */
    @PreAuthorize("@ss.hasPermi('student:scores:export')")
    @Log(title = "成绩信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StuScores stuScores)
    {
        List<StuScores> list = stuScoresService.selectStuScoresList(stuScores);
        ExcelUtil<StuScores> util = new ExcelUtil<StuScores>(StuScores.class);
        util.exportExcel(response, list, "成绩信息数据");
    }

    /**
     * 获取成绩信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('student:scores:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(stuScoresService.selectStuScoresById(id));
    }

    /**
     * 新增成绩信息
     */
    @PreAuthorize("@ss.hasPermi('student:scores:add')")
    @Log(title = "成绩信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuScores stuScores)
    {
        return toAjax(stuScoresService.insertStuScores(stuScores));
    }

    /**
     * 修改成绩信息
     */
    @PreAuthorize("@ss.hasPermi('student:scores:edit')")
    @Log(title = "成绩信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuScores stuScores)
    {
        return toAjax(stuScoresService.updateStuScores(stuScores));
    }

    /**
     * 删除成绩信息
     */
    @PreAuthorize("@ss.hasPermi('student:scores:remove')")
    @Log(title = "成绩信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(stuScoresService.deleteStuScoresByIds(ids));
    }
}
